<!DOCTYPE html>
<html>

<head lang="en">
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="description" content="">
    <meta name="keywords" content="">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
    <title>南京大学职业咨询室预约平台</title>
    <!-- Set render engine for 360 browser -->
    <meta name="renderer" content="webkit">
    <!-- No Baidu Siteapp-->
    <meta http-equiv="Cache-Control" content="no-siteapp"/>
    <link rel="icon" type="image/x-icon" href="{{ url_for('static', filename='assets/i/ico_128X128.ico') }}">
    <!-- Add to homescreen for Chrome on Android -->
    <meta name="mobile-web-app-capable" content="yes">
    <link rel="icon" sizes="192x192" href="{{ url_for('static', filename='assets/i/app-icon72x72@2x.png') }}">
    <!-- Add to homescreen for Safari on iOS -->
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-title" content="Amaze UI"/>
    <link rel="apple-touch-icon-precomposed" href="{{ url_for('static', filename='assets/i/app-icon72x72@2x.png') }}">
    <!-- Tile icon for Win8 (144x144 + tile color) -->
    <meta name="msapplication-TileImage" content="{{ url_for('static', filename='assets/i/app-icon72x72@2x.png') }}">
    <meta name="msapplication-TileColor" content="#0e90d2">

    <link rel="stylesheet" href="{{ url_for('static', filename='assets/css/amazeui.min.css') }}">
    <link rel="stylesheet" href="{{ url_for('static', filename='assets/css/app.css', v='1.4') }}">
    <script src="{{ url_for('static', filename='assets/js/jquery.min.js') }}"></script>
    <script src="{{ url_for('static', filename='assets/js/amazeui.min.js') }}"></script>

</head>

<body>
<div class="admin-header">
    <!--<div class="header-back" onclick="history.back()">返回</div>-->
    <div class="header-title">记录列表</div>
</div>
<div class="content">
    {% for li in lists %}
    <div class="book-item-warp">
        <div class="book-item-title">
            <div class="fl"> <strong>预约序号：</strong>{{li['seq']}}</div>
        </div>
        <div class="book-item-line">
            <div class="fl"> <strong>学生姓名：</strong>{{ li['stuname'] }}</div>
            <div class="fr"> <strong>编号：</strong>{{ li['stuid'] }}</div>
        </div>
        <div class="book-item-line">
            <div class="fl"> <strong>教师姓名：</strong>{{ li['tchname'] }}</div>
            <div class="fr"> <strong>编号：</strong>{{ li['tchid'] }}</div>
        </div>
        <div class="book-item-line">
            <div class="fl"> <strong>咨询内容：</strong>{{li['content']}}</div>
        </div>
        <div class="book-item-line">
            <div class="fl"> <strong>咨询日期：</strong>{{li['date']}}</div>
        </div>
         <div class="book-item-line">
            <div class="fl"> <strong>需求：</strong>{{li['demands']}}</div>
        </div>
        <div class="book-item-line">
            <div class="fl"> <strong>反馈：</strong>{{li['feedback']}}</div>
        </div>
        <div class="book-item-line">
            <div class="fl"> <strong>咨询状态：</strong>{{li['status']}}</div>
            {% if li['replace'] %}
            <div class="fr"> <button value="{{li['seq']}}" class="am-btn am-btn-primary am-btn-sm" onclick="cacel_boot(this,this.value)"><i class="am-icon-remove"></i>取消预约</button></div>
            {% endif %}
        </div>
        {% if li['replace'] %}
        <div class="book-item-line">
            <div class="fr"> <button onclick="var label1 = document.getElementById('set_replace_{{li['seq']}}');label1.style.display='block';" class="am-btn am-btn-danger am-btn-sm"><i class="am-icon-plus"></i>设置顶班</button></div>
        </div>
        <div id="set_replace_{{li['seq']}}" style="display:none;">
            <div class="book-item-line">
                <div> <input id="replace_{{li['seq']}}" style="width:100%;" type="text" value="" class="am-form-field" placeholder="顶班咨询师编号">
                </div>
                <div> <input id="replace_reason_{{li['seq']}}" style="width:100%;" type="text" value="" class="am-form-field" placeholder="顶替排班理由">
                </div>
            </div>
            <div class="book-item-line">
                <div class="fr"> <button value="{{li['seq']}}" class="am-btn am-btn-primary am-btn-sm" onclick="commit_replace(this,this.value)">提交顶班</button></div>
            </div>
        </div>
        {% endif %}
    </div>
     {% endfor %}

    <div class="am-cf">
        <button type="text" id="back_" value="返回" onclick="javascript:window.location.href='./admin_get_records_page';" class="am-btn am-btn-default">返&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;回</button>
    </div>

    <form method="post" action="/">

    </form>
</div>

<script type="text/javascript">
function commit_replace(obj,val)
{
    var replace_seq = $("#replace_"+val).val();
    var replace_reason = $("#replace_reason_"+val).val();
    
    if (replace_seq==null || replace_seq=="") {
        alert("请输入顶班咨询师编号");
        return false;
    };
    
    if (replace_seq==val) {
        alert("顶班咨询师和当前咨询师编号相同，请重新输入");
        return false;
    };
    
    if (replace_reason==null || replace_reason=="") {
        alert("请输入顶替排班的理由");
        return false;
    };
    
    var csrftoken = $('meta[name=csrf-token]').attr('content');$.ajaxSetup({beforeSend: function(xhr, settings) {if (!/^(GET|HEAD|OPTIONS|TRACE)$/i.test(settings.type) && !this.crossDomain) {xhr.setRequestHeader("X-CSRFToken", csrftoken)} }});
    $.ajax({type: 'post',url: '/admin_set_replace',data: {seq: val,rp_seq:replace_seq,rp_rs:replace_reason},async: 0,success: function(data) {
        alert(data.msg);
        if (data.ret) {
            window.location.href = './admin_get_records_page';
        }
    },error: function() {alert('服务端异常');}});
}

function cacel_boot(obj,val)
{
    conf = window.confirm("确定取消咨询？");
    if (conf) {
        var csrftoken = $('meta[name=csrf-token]').attr('content');$.ajaxSetup({beforeSend: function(xhr, settings) {if (!/^(GET|HEAD|OPTIONS|TRACE)$/i.test(settings.type) && !this.crossDomain) {xhr.setRequestHeader("X-CSRFToken", csrftoken)} }});
        $.ajax({type: 'post',url: '/admin_cancel_record',data: {seq: val,cancel_rs:""},async: 0,success: function(data) {
            alert(data.msg);
            if (data.ret) {
                window.location.href = './admin_get_records_page';
            }
        },error: function() {alert('服务端异常');}});
        
        return true;
    }
    
    return false;
}
</script>
</body>

</html>
